package com.keyinong.qudan.tools;

import android.content.Context;
import android.util.Log;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class HttpTools {
	Context context;
	AsyncHttpClient client=new AsyncHttpClient();
	
	public HttpTools(Context context) {
		super();
		this.context = context;
	}
	/**登录*/
	public void login(String phone, String password,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("phone", phone);
		params.put("password", password);
		client.post(context, Url.loginUrl, params, backcall);
	}
	/**确认*/
	public void queren(String token, String orderid,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Url.querenUrl, params, backcall);
	}
	/**已完成*/
	public void yiwancheng(String token, String orderid,String state,String paymode,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		params.put("state", state);
		params.put("paymode", paymode);
		client.post(context, Url.querenUrl, params, backcall);
	}
	/**订单列表*/
	public void order(String token, String page,String offset,String type,String recmode,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("page", page);
		params.put("offset", offset);
		params.put("type", type);
		params.put("recmode", recmode);
		client.post(context, Url.orderUrl, params, backcall);
	}
	/**订单详情*/
	public void detail(String token, String orderid,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		Log.e("lh", "detailurl=="+Url.detailUrl);
		client.post(context, Url.detailUrl, params, backcall);
	}
	
	/**打印订单*/
	public void printorder(String token, String orderid,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Url.printorderUrl, params, backcall);
	}
	
	/**取消订单*/
	public void cancleorder(String token, String orderid,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Url.cancleorderUrl, params, backcall);
	}
	/**达达订单*/
	public void dadaadd(String token, String orderid,
			JsonHttpResponseHandler backcall) {
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Url.queryfee, params, backcall);
	}
	
	/**达达预发布*/
	public void queryfee(String token, String orderid,
			JsonHttpResponseHandler backcall){
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		client.post(context, Url.queryfee, params, backcall);
		
	}
	
	/**发送给达达*/
	public void addAfterQuery(String token,String deliveryno,String orderid,
			JsonHttpResponseHandler backcall){
		RequestParams params = new RequestParams();
		params.put("token", token);
		params.put("orderid", orderid);
		params.put("deliveryno", deliveryno);
		client.post(context, Url.addAfterQuery, params, backcall);
	}
	
	
}
